/**
 * 任务配置 api 封装
 *
 * @Author:    KeissCake
 * @Date:      2024-09-26 21:17:52
 * @Copyright  暂无
 */
import { postRequest, getRequest } from '/src/lib/axios';

export const datataskApi = {

  /**
   * 分页查询  @author  KeissCake
   */
  queryPage : (param) => {
    return postRequest('/datatask/queryPage', param);
  },

  /**
   * 增加  @author  KeissCake
   */
  add: (param) => {
      return postRequest('/datatask/add', param);
  },

  /**
   * 修改  @author  KeissCake
   */
  update: (param) => {
      return postRequest('/datatask/update', param);
  },


  /**
   * 删除  @author  KeissCake
   */
  delete: (id) => {
      return getRequest(`/datatask/delete/${id}`);
  },

  /**
   * 批量删除  @author  KeissCake
   */
  batchDelete: (idList) => {
      return postRequest('/datatask/batchDelete', idList);
  },
    /**
     * 更新状态
     * @param status
     * @param taskId
     * @returns {Promise<axios.AxiosResponse<any>>}
     */
  updateStatus: (status, taskId) =>{
      return postRequest('/datatask/updateStatus', {status, taskId});
  },
  getStatus: (taskId) =>{
      return getRequest('/datatask/queryStatus',{taskId})
  },
    /**
     * 添加新任务
      * @param dataSourceId
     */
  addTask:(dataSourceId)=>{
      return postRequest('/datatask/addTask',{dataSourceId})
  },
  getSQL:(taskId) =>{
      return getRequest('/getCode/getSqlString',{taskId})
  },
  //获取 数据源类型
  getSourceType: (dataSourceId) => {
      return getRequest('/datatask/queryDataSourceType', {dataSourceId});
  },
  preview: (taskId) => {
      return getRequest('/getCode/preview', {taskId});
  }
};
